package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.common.constants.ArticleConstants;
import com.heima.model.article.dtos.ApArticleDto;
import com.heima.model.article.dtos.ApArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2023/3/14 9:47
 * @Version 1.0
 */
@RestController
//@RequestMapping("/api/v1/article")
public class ApArticleController{

    @Autowired
    private ApArticleService articleService;

    @PostMapping("/api/v1/article/load")
    public ResponseResult load(@RequestBody ApArticleHomeDto homeDto){
        return articleService.load(homeDto, ArticleConstants.LOAD_MORE);
    }

    @PostMapping("/api/v1/article/loadmore")
    public ResponseResult loadMore(@RequestBody ApArticleHomeDto homeDto){
        return articleService.load(homeDto,ArticleConstants.LOAD_MORE);
    }

    @PostMapping("/api/v1/article/loadnew")
    public ResponseResult loadNew(@RequestBody ApArticleHomeDto homeDto){
        return articleService.load(homeDto,ArticleConstants.LOAD_NEW);
    }

    @PostMapping("/api/v1/article/save")
    public ResponseResult save(@RequestBody ApArticleDto articleDto){
        return articleService.saveArticle(articleDto);
    }

    @PostMapping("/api/v1/article/queryArticleId")
    public List<Integer> queryArticleId(){
        return articleService.queryChannelId();
    }
}